import mongoose, { Schema } from 'mongoose';

export interface IUser {
  username: string;
  password: string;
  email?: string;
  created_at: number;
  updated_at: number;
  avatar?: string | undefined;
}
const userSchema = new Schema({
  username: { type: String, required: true }, // 用户名称
  password: { type: String, required: true }, // 密码
  email: { type: String, unique: true }, // 邮箱
  avatar: { type: String }, // 头像
  created_at: { type: Number, default: Date.now }, // 创建时间
  updated_at: { type: Number, default: Date.now }, // 更新时间
});

const UserModel = mongoose.model('users', userSchema);

export default UserModel;
